<%@ page contentType="text/html; charset=utf-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="thx" uri="/thx-tags" %>
<%@ taglib prefix="fun" uri="http://java.sun.com/jsp/jstl/functions" %>

<section class="content-header">
	<h1>
		应用管理<small>应用流程</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
		<li><a href="#">应用流程管理</a></li>
		<li class="active">应用管理</li>
	</ol>
</section>

<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box">
				<div class="box-header with-border">
					<form class="search-panel" action="/workflow/appConfig!list.action" name="search-form">
	          		<div class="row">
		          		<div class="search-panel">
							<input type="text" name="entity.appName" value="${entity.appName}" class="form-control" placeholder="应用名称">
							<button type="button" class="btn btn-primary search-btn"  >搜索</button>
						 </div>
					</div>
					</form>
				</div>
				<div class="box-body no-padding">
            	<div class="row">
                	<div class="col-sm-12">
            		<form id="app-data-form">
						<table class="table table-bordered">
							<tr>
			                	<th>序号</th>
			                	<th>应用</th>
			                	<th>分类</th>
			                	<th>描述</th>
			                	<th>是否完成</th>
			                    <th>操作</th>
			                </tr>
							<c:if test="${empty list}">
			                <tr>
			                	<td colspan="6">
			                		暂无数据！
			                	</td>
			                </tr>
			                </c:if>
			                <c:forEach items='${list}' var="app">
			                <tr>
			                	<td>
			                		<input type="hidden" name="appIds" value="${app.appId}">
			                		<input type="text" style="width:30px;text-align:center;" name="appOrders" value="${app.appOrder}">
			                	</td>
			                	<td>${app.appName}</td>
			                	<td>${app.appType.typeName}</td>
			                	<td>${app.appDescribe}</td>
			                	<td>
			                		<c:choose>
			                			<c:when test="${app.isComplete=='1'}">已完成</c:when>
			                			<c:when test="${app.isComplete=='0'}">未完成</c:when>
			                		</c:choose>
			                	</td>
			                    <td>
									<button type="button" title="应用修改" data-toggle="tooltip"
											data-placement="bottom" width="900" isFullScreen="false"
											open-url="workflow/appConfig!input.action?id=${app.appId}"
											class="btn btn-default btn-sm btn-open-win">
											<i class="fa fa-edit"></i>
										</button>
									<button type="button" title="应用删除" 
											data-toggle="tooltip"
											do-url="workflow/appConfig!delete.action?id=${app.appId}"
											load-url="workflow/appConfig!list.action"
											confirm-msg="确定要删除吗？"
											class="btn btn-default btn-sm btn-open-confirm-win">
											<i class="fa fa-trash"></i>
									</button>
									<button type="button"
											title="应用复制"
											data-toggle="tooltip"
											open-url="workflow/appConfig!toCopy.action?applicationId=${app.appId}"
											class="btn btn-default btn-sm btn-open-form">
											<i class="fa fa-copy"></i>
									</button>
								</td>
			                </tr>
			                </c:forEach>
						</table>
            		</form>
					</div>
				</div>
				<div class="box-footer">
					 <!--分页区-->
					<div class="pagePanel">
			           	 <thx:pages pageNo="page.curPage" total="page.totalPage"  theme="number">
			           	 	<s:param name="entity.appName" value="entity.appName"></s:param>
						</thx:pages>
					</div>
					 <!--底部操作区-->
					<div class="handlePanel">
						<a title="新建应用" class="a-btn btn-open-win"
							data-toggle="tooltip"
							width="900" isFullScreen="false"
							open-url="workflow/appConfig!input.action"> 
							<span class="fa fa-plus"></span> 
							<span class="text">新增</span>
						</a>
						<a title="排序保存" class="a-btn saveOrder"
							data-toggle="tooltip">
							<span class="fa fa-save"></span> 
							<span class="text">保存排序</span>
						</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<script>
$(function() {
	page.init();
	list.init();

	function saveCallBack(id,modal) {
		$.ajax({
			url : '${pageContext.request.contextPath}/workflow/appConfig!saveAppOrder.action',
			type : 'post',
			data : $("#app-data-form").serialize(),
			success : function(msg) {
	           	if(msg=='success'){
	             dialog.alert("操作成功!");
	             Util.ajaxPage(ctxPath + "/workflow/appConfig!list.action",'');
	           	}else{
	             dialog.alert("操作失败!");
	           	}
			}
		});
    };

	$(".saveOrder").click(function(){
		dialog.confirm("",saveCallBack,null,"确认保存排序?");
	});
});
</script>